package mysql

import (
	"gorm.io/gorm"
)

type Reservation struct {
	gorm.Model
	UserId    int64  `gorm:"int;"`
	ClassName string `gorm:"type:varchar(100);"`
	AddTime   string `gorm:"type:date;"`
	Address   string `gorm:"type:varchar(255);"`
	Teacher   string `gorm:"char(10);"`
	Status    int64  `gorm:"type:int;default:0"`
	Context   string `gorm:"type:varchar(200)"`
}

func (r *Reservation) CreateFitness(className, addTime, address, teacher, context string) error {
	fit := &Reservation{
		ClassName: className,
		AddTime:   addTime,
		Address:   address,
		Teacher:   teacher,
		Status:    0,
		Context:   context,
	}
	err := DB.Debug().Create(&fit).Error
	if err != nil {
		return err
	}
	return nil
}
func (r *Reservation) FindReservationById(id int64) (fit []*Reservation, err error) {
	err = DB.Debug().Where("id=?", id).Find(&fit).Error
	if err != nil {
		return nil, err
	}
	return fit, nil
}
